//
//  CommonNewsTableViewCell.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 17/5/2.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "CommonNewsTableViewCell.h"

@implementation CommonNewsTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

/**  120  */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self layoutUI];
       
        
        UIView *under1 = [UIView new];
        under1.backgroundColor = [UIColor themeGrayColor];
        [self addSubview:under1];
        under1.sd_layout.leftEqualToView(self).bottomEqualToView(self).widthIs([UIScreen zj_screenWith]).heightIs(10 * [UIScreen zj_screenHScale]);
        
    }
    return self;
}

#pragma mark - 界面
- (void)layoutUI{
    [self addSubview:self.commonImageView];
    [self addSubview:self.timeLabel];
    [self addSubview:self.detaiLbale];
    
    
    self.commonImageView.sd_layout
    .topSpaceToView(self,10 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self,15 * [UIScreen zj_screenWScale])
    .heightIs(90 * [UIScreen zj_screenHScale])
    .widthIs(140 * [UIScreen zj_screenWScale]);
    
    self.timeLabel.sd_layout
    .bottomEqualToView(self.commonImageView)
    .leftSpaceToView(self.commonImageView,12 * [UIScreen zj_screenWScale])
    .heightIs(10 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith] - 180 * [UIScreen zj_screenWScale]);
    
    self.detaiLbale.sd_layout
    .topEqualToView(self.commonImageView)
    .leftEqualToView(self.timeLabel)
    .widthIs(self.timeLabel.width)
    .heightIs(self.commonImageView.height - 15 * [UIScreen zj_screenHScale]);
    
    
   
    
}


#pragma mark - 私有方法
//- (void)setModel:(LPMenuOneModel *)model{
//    _model = model;
//    self.timeLabel.text = @"2017.03.17";
//    self.commonImageView.image = [UIImage imageNamed:@""];
//    self.commonImageView.backgroundColor = [UIColor randomColor];
//    
//    /**  设置行距  */
//    NSMutableAttributedString *text2 = [[NSMutableAttributedString alloc] initWithString:@"习近平参加辽宁省调研报告说我们海华丝覅不死神的发生的理发师"];
//    
//    NSMutableParagraphStyle *style2 = [[NSMutableParagraphStyle alloc] init];
//    style2.headIndent = 0;
//    style2.lineSpacing = 6 * [UIScreen zj_screenHScale];
//    [text2 addAttribute:NSParagraphStyleAttributeName value:style2 range:NSMakeRange(0, text2.length)];
//    
//    self.detaiLbale.attributedText = text2;
//    if (model.HEIGHT < self.commonImageView.height - 15 * [UIScreen zj_screenHScale]) {
//        self.detaiLbale.sd_layout.heightIs(model.HEIGHT);
//    }
//
//}


#pragma mark - getter
- (UIImageView *)commonImageView{
    if (!_commonImageView) {
        _commonImageView = [UIImageView new];
        _commonImageView.contentMode = UIViewContentModeCenter;
    }
    return _commonImageView;
}

- (UILabel *)detaiLbale{
    if (!_detaiLbale) {
        _detaiLbale = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textBlackColor];
            label.numberOfLines = 3;
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:14 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _detaiLbale;
}

- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor lightGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:13 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _timeLabel;
}

@end
